<?php
/**
 * This example creates a test network. You do not need to have a DFP account to
 * run this example, but you do need to have a Google account (created at
 * http://www.google.com/accounts/newaccount if you currently don't have one)
 * that is not associated with any other DFP test networks. Once this network is
 * created, you can supply the network code in your settings to make calls to
 * other services. Please note that a Google account can create one test
 * network; any future calls to makeTestNetwork will fail.
 *
 * Alternatively, if you do not wish to run this example, you can create a test
 * network at:
 * https://dfp-playground.appspot.com
 *
 * Tags: NetworkService.getCurrentNetwork
 * Tags: NetworkService.makeTestNetwork
 *
 * PHP version 5
 *
 * Copyright 2012, Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package    GoogleApiAdsDfp
 * @subpackage v201208
 * @category   WebServices
 * @copyright  2012, Google Inc. All Rights Reserved.
 * @license    http://www.apache.org/licenses/LICENSE-2.0 Apache License,
 *             Version 2.0
 * @author     Paul Rashidi <api.paulrashidi@gmail.com>
 */

error_reporting(E_STRICT | E_ALL);

// You can set the include path to src directory or reference
// DfpUser.php directly via require_once.
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';

try {
  // Get DfpUser from credentials in "../auth.ini"
  // relative to the DfpUser.php file's directory.
  $user = new DfpUser();

  // Log SOAP XML request and response.
  $user->LogDefaults();

  // Get the NetworkService.
  $networkService = $user->GetService('NetworkService', 'v201208');

  // Make the test network.
  $network = $networkService->makeTestNetwork();

  print 'Test network with network code "' . $network->networkCode
    . '" and display name "' . $network->displayName . "\" created.\n"
    . ' You may now sign in at http://www.google.com/dfp/main?networkCode='
    . $network->networkCode . "\n";
} catch (Exception $e) {
  print $e->getMessage() . "\n";
}
